package org.pi.common.gui.clipboard

import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.image.BufferedImage;

class ClipImage(private val myImage: BufferedImage) extends Transferable {
	private val myFlavors = Array[DataFlavor](DataFlavor.imageFlavor);

	override def getTransferDataFlavors(): Array[DataFlavor] = myFlavors
	override def isDataFlavorSupported(flavor: DataFlavor): Boolean = (flavor == DataFlavor.imageFlavor)

	override def getTransferData(flavor: DataFlavor): Object = { // throws UnsupportedFlavorException 
		if (flavor != DataFlavor.imageFlavor) {
			throw new UnsupportedFlavorException(flavor);
		}
		myImage;
	}
}
